'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    // 定义类目数据，包含1-4级的父子关系结构
    const categories = [
      // 一级类目
      {
        id: 1,
        name: '办公用品',
        parent_id: null,
        level: 1,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 2,
        name: '数码产品',
        parent_id: null,
        level: 1,
        sort: 2,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 3,
        name: '家具用品',
        parent_id: null,
        level: 1,
        sort: 3,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      
      // 二级类目
      {
        id: 4,
        name: '文具用品',
        parent_id: 1,
        level: 2,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 5,
        name: '办公耗材',
        parent_id: 1,
        level: 2,
        sort: 2,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 6,
        name: '存储设备',
        parent_id: 2,
        level: 2,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 7,
        name: '办公家具',
        parent_id: 3,
        level: 2,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      
      // 三级类目
      {
        id: 8,
        name: '笔类',
        parent_id: 4,
        level: 3,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 9,
        name: '本册类',
        parent_id: 4,
        level: 3,
        sort: 2,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 10,
        name: '打印纸',
        parent_id: 5,
        level: 3,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 11,
        name: 'U盘',
        parent_id: 6,
        level: 3,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 12,
        name: '移动硬盘',
        parent_id: 6,
        level: 3,
        sort: 2,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 13,
        name: '办公桌',
        parent_id: 7,
        level: 3,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 14,
        name: '办公椅',
        parent_id: 7,
        level: 3,
        sort: 2,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      
      // 四级类目
      {
        id: 15,
        name: '中性笔',
        parent_id: 8,
        level: 4,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 16,
        name: '圆珠笔',
        parent_id: 8,
        level: 4,
        sort: 2,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 17,
        name: '笔记本',
        parent_id: 9,
        level: 4,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 18,
        name: 'A4打印纸',
        parent_id: 10,
        level: 4,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 19,
        name: '固态硬盘',
        parent_id: 12,
        level: 4,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      },
      {
        id: 20,
        name: '人体工学椅',
        parent_id: 14,
        level: 4,
        sort: 1,
        status: 'active',
        created_at: new Date(),
        updated_at: new Date()
      }
    ];

    // 插入数据
    await queryInterface.bulkInsert('product_categories', categories, {});
  },

  down: async (queryInterface, Sequelize) => {
    // 删除所有类目数据
    await queryInterface.bulkDelete('product_categories', null, {});
  }
};